//
//  Task_ModityRegister.m
//  wmh.ios.v5
//
//  Created by AndLi on 14-9-2.
//  Copyright (c) 2014年 Epoint. All rights reserved.
//

#import "Task_ModityRegister.h"
#import "MDUtil.h"

@implementation Task_ModityRegister
-(void)execute
{
    
    NSString *url = NSLocalizedString(@"Epoint_DNet_WMH", @"");
    NSString *ValidateData = [EpointBizTools getToken];
    NSString *namespace = NSLocalizedString(@"Epoint_DNet_WMH_NameSpace", @"");
    
    NSString *loginid = [params objectForKey:@"loginid"];
    NSString *name = [params objectForKey:@"name"];
    NSString *phone = [params objectForKey:@"phone"];
    NSString *email = [params objectForKey:@"email"];
    NSString *address = [params objectForKey:@"address"];
    NSString *password = [params objectForKey:@"password"];

    
    NSString *method = @"ModityRegister";
    NSString *ParasXml = @"<![CDATA[<?xml version=\"1.0\" encoding=\"gb2312\"?><paras><loginid>%@</loginid><name>%@</name><phone>%@</phone><email>%@</email><address>%@</address><password>%@</password></paras>]]>";
    ParasXml = [NSString stringWithFormat:ParasXml,loginid,name,phone,email,address,password];
    
    EpointWebServiceUtil *ws = [[EpointWebServiceUtil alloc]initWithUrl:url namespace:namespace method:method];
    [ws addParameterForString:@"ValidateData" value:ValidateData];
    [ws addParameterForString:@"ParasXml" value:ParasXml];
    NSString *bs =  ws.start;
    
    NSMutableArray *result = [self validateXMLWS2:bs];
    NSString *msg = [result objectAtIndex:1];
    if ([[result objectAtIndex:0]isEqualToString:@"1"]) {
        NSString *userinfo =@"<?xml version=\"1.0\" encoding=\"gb2312\" ?><EpointDataBody><DATA><ReturnInfo><Status>True</Status><Description></Description></ReturnInfo><UserArea><name>%@</name><email>%@</email><phone>%@</phone><address>%@</address><logintimes>0</logintimes></UserArea></DATA></EpointDataBody>";
        userinfo = [NSString stringWithFormat:userinfo,name,email,phone,address];
        [DBFrameService setConfigValue:WMH_UserInfo value:userinfo];

        [self exeSuccessWithData:bs];
        
    }
    else
    {
        [self exeFailureWithMessage:msg];
    }
    
}
@end
